<?php

class AuthorIDBehavior extends CActiveRecordBehavior
{

    public function beforeSave($event)
    {
        if ($this->owner->isNewRecord)
        {
            $this->owner->user_id = yii::app()->user->id;
            $this->owner->user_name = yii::app()->user->getModel()->username;
        }
    }

}

?>